import React, { Component } from 'react';
import { TenantC, TenantDepartmentC, SecondHeaderC } from '../../../components';
import { Form } from 'antd';

class Tenant extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true,
      initialValue: undefined,
    };
  }

  refInstance = React.createRef();

  componentDidMount() {
    this.setState({
      forminit: this.refInstance.current,
    });
    setTimeout(() => {
      this.setState({
        initialValue: ['WZYTEST'],
      });
    }, 2000);
  }

  render() {
    return (
      <div style={{ width: '800px', padding: '20px' }}>
        <div>
          <SecondHeaderC title='租户' />
          <Form ref={this.refInstance}>
            <TenantC form={this.refInstance.current} dataIndex='tenant' helper='lalal' onChange={(e) => console.log(e)} />
            <TenantC form={this.refInstance.current} dataIndex='tenant1' onChange={(e) => console.log(e)} rules={[{ required: true, message: '请选择租户!' }]} multiple={true} />
            <TenantC
              title={'同步初始值'}
              initialValue={['WZYTEST']}
              form={this.refInstance.current}
              dataIndex='tenant2'
              onChange={(e) => console.log(e)}
              rules={[{ required: true, message: '请选择租户!' }]}
              multiple={true}
            />
            <TenantC
              title={'异步初始值'}
              initialValue={this.state.initialValue}
              form={this.refInstance.current}
              dataIndex='tenant3'
              onChange={(e) => console.log(e)}
              rules={[{ required: true, message: '请选择租户!' }]}
              multiple={true}
            />
            <SecondHeaderC title={localStorage.getItem('antd-pro-superMan') == 'true' ? '租户+部门（超户）/默认定位第一个' : '租户+部门（普通用户）'} />
            <TenantDepartmentC
              form={this.refInstance.current}
              dataIndex='tenantDepartmentC'
              firstInit={true}
              tenantOnChange={(e) => console.log(e)}
              departmentChange={(e) => console.log(e)}
            />
          </Form>
        </div>
      </div>
    );
  }
}

export default Tenant;
